--[[ 
	oUF_Jie - Layout for oUF
	Change from oUF_Lighterfluid	
--]]

-- Locals baby!
local _G = getfenv(0)
local select = select
local UnitIsPlayer = UnitIsPlayer
local UnitIsDead = UnitIsDead
local UnitIsGhost = UnitIsGhost
local UnitIsConnected = UnitIsConnected
local RAID_CLASS_COLORS = RAID_CLASS_COLORS
local UnitClass = UnitClass
local UnitReactionColor = UnitReactionColor
local UnitReaction = UnitReaction
local UnitIsPVP = UnitIsPVP
local UnitCreatureType = UnitCreatureType
local UnitClassification = UnitClassification
-- Global reference for fonts/textures.
local font = "fonts\\FRIZQT__.ttf"
local statusbar = "Interface\\AddOns\\oUF_Jie\\textures\\Glaze.tga"
local buffborder = "Interface\\AddOns\\oUF_Jie\\textures\\buffborder.tga"

--  Lib support locals
local LibMobHealth, LibDruidMana, druidMana
if LibStub then LibMobHealth = LibStub("LibMobHealth-4.0", true) end
if LibStub then LibDruidMana = LibStub("LibDruidMana-1.0", true) end

-- add combo points/druidmana listener if rogue/druid
local class = select(2, UnitClass"player")
local combo = 
		(class=="ROGUE" and true) or 
		(class=="DRUID" and true) or
		false

local menu = function(self)
	local unit = self.unit:sub(1, -2)
	local cunit = self.unit:gsub("(.)", string.upper, 1)

	if(unit == "party" or unit == "partypet") then
		ToggleDropDownMenu(1, nil, _G["PartyMemberFrame"..self.id.."DropDown"], "cursor", 0, 0)
	elseif(_G[cunit.."FrameDropDown"]) then
		ToggleDropDownMenu(1, nil, _G[cunit.."FrameDropDown"], "cursor", 0, 0)
	end
end

-- druid function taken from p3lim
if LibDruidMana and combo then 
	LibDruidMana:AddListener(function(currMana, maxMana)
		local perc = string.format("%d%%", (currMana/maxMana)*100)
		druidMana:SetText((currMana==maxMana and "") or "|cff33AAEE"..perc.."|r")
	end)
end	

-- level function
local updateLevel = function(self, unit, name)
	local level = UnitLevel(unit)
	local c = GetDifficultyColor(level)
	local creaturetype = UnitCreatureType(unit)
	local classification = UnitClassification(unit)
	if level < 0 then level = "??" end
	
	if UnitIsPlayer(unit) then	
		self.Level:SetText(level)
		self.Class:Hide()
	else
		self.Class:Show()
		if classification == "elite" then
			self.Level:SetText("+"..level)
		elseif classification == "rareelite" then
			self.Level:SetText("+"..level.."Rare")
		elseif classification == "rare" then
			self.Level:SetText(level.."Rare")
		else
			self.Level:SetText(level)
		end
		if classification == "worldboss" then
			self.Class:SetText("|cffff0000Boss|r")
		else
			self.Class:SetText(creaturetype)
		end
	end
	self.Level:SetTextColor(c.r, c.g, c.b)
end

-- name function
local updateName = function(self, event, unit)
	if(self.unit ~= unit) then return end

	local name = UnitName(unit)
	if(UnitIsTapped(unit) and not UnitIsTappedByPlayer(unit) or not UnitIsConnected(unit)) then
		self.Name:SetTextColor(.6, .6, 6)	
	else
		local color = UnitIsPlayer(unit) and RAID_CLASS_COLORS[select(2, UnitClass(unit))] or UnitReactionColor[UnitReaction(unit, "player")]
		if(color) then self.Name:SetTextColor(color.r, color.g, color.b) end
	end

	self.Name:SetText(name)
	if unit == "target" then
		updateLevel(self, unit, name)
	end
end

local numberize = function(v)
	if v <= 9999 then return v end
	if v >= 1000000 then
		local value = string.format("%.1fM", v/1000000)
		return value
	elseif v >= 10000 then
		local value = string.format("%.1fk", v/1000)
		return value
	end
end

-- raid health function
-- miss = missing hp(deficit) // perc = percentage // cur and maxhp are self explanatory
local updateraidHealth = function(self, event, bar, unit, min, max)
	local missing = max-min
	local perc = string.format("%d%%", min/max*100)
	local miss = "-"..numberize(missing)
	if(UnitIsDead(unit)) then
		bar.value:SetText("")
		self.Missing:SetText("Dead")
	elseif(UnitIsGhost(unit)) then
		bar.value:SetText("")
		self.Missing:SetText("Ghost")
	elseif(not UnitIsConnected(unit)) then
		bar.value:SetText("")
		self.Missing:SetText("Offline")
	else
		bar.value:SetText(perc)
		self.Missing:SetText((missing > 0 and "|cffff0000"..miss.."|r") or "")
	end
	
	bar:SetStatusBarColor(0.45, 0.45, 0.45)
	if(not UnitIsConnected(unit)) then
		self.Name:SetTextColor(.6, .6, .6)
		self.Power:SetStatusBarColor(.6, .6, .6)
	else
		self:UNIT_NAME_UPDATE(self, event, unit)
	end
end

-- health function
-- perc = percentage // cur and maxhp are self explanatory
local updateHealth = function(self, event, bar, unit, min, max)
	local cur, maxhp
	if LibMobHealth then 
		cur, maxhp = LibMobHealth:GetUnitHealth(unit) -- Call LibMobHealth-4.0 support
	elseif MobHealth3 then 
		cur, maxhp = MobHealth3:GetUnitHealth(unit) -- Call MobHealth3 support
	else 
		cur, maxhp = min, max
	end
	local curhp = numberize(cur)
	local maxhp2 = numberize(maxhp)
	local perc = string.format("%d%%", min/max*100)
	if unit:match"raid" then
		updateraidHealth(self, event, bar, unit, min, max)
	elseif(UnitIsDead(unit)) then
		bar:SetValue(0)
		bar.value:SetText"Dead"
	elseif(UnitIsGhost(unit)) then
		bar:SetValue(0)
		bar.value:SetText"Ghost"
	elseif(not UnitIsConnected(unit)) then
		bar.value:SetText"Offline"
	elseif unit == "pet" or unit == "targettarget" then
		bar.value:SetText(perc)
	elseif unit == "player" then
		bar.value:SetText("|cff33EE44"..curhp.."|r [|cff33EE44"..maxhp2.."|r]")
	elseif unit == "target" then
		bar.value:SetText("[|cff33EE44"..maxhp2.."|r] |cff33EE44"..curhp.."|r ")
	else
		bar.value:SetText(curhp.." ["..maxhp2.."]")
	end
	
	bar:SetStatusBarColor(0.45, 0.45, 0.45)
	if(UnitIsTapped(unit) and not UnitIsTappedByPlayer(unit) or not UnitIsConnected(unit)) then
		self.Name:SetTextColor(.6, .6, .6)
		self.Power:SetStatusBarColor(.6, .6, .6)
	else
		local color = UnitIsPlayer(unit) and RAID_CLASS_COLORS[select(2, UnitClass(unit))] or UnitReactionColor[UnitReaction(unit, "player")]
		if(color) then self.Health:SetStatusBarColor(color.r, color.g, color.b) end
		self:UNIT_NAME_UPDATE(self, event, unit)
	end
	
end

-- power function
local updatePower = function(self, event, bar, unit, min, max)
	if(min == 0) then
		bar.value:SetText()
	elseif(UnitIsDead(unit)) then
		bar:SetValue(0)
	elseif(UnitIsGhost(unit)) then
		bar:SetValue(0)
	elseif unit == "player" then 
		bar.value:SetText("[|cff33AAEE"..numberize(max).."|r] |cff33AAEE"..numberize(min).."|r")
	elseif unit == "target" then
		bar.value:SetText("|cff33AAEE"..numberize(min).."|r [|cff33AAEE"..numberize(max).."|r]")
	else
		bar.value:SetText(numberize(min).." ["..numberize(max).."]")
	end

	if(UnitIsTapped(unit) and not UnitIsTappedByPlayer(unit) or not UnitIsConnected(unit)) then
		bar:SetStatusBarColor(.6, .6, .6)
	elseif(unit == "pet" and GetPetHappiness()) then
		local color = oUF.colors.happiness[GetPetHappiness()]
		self.Power:SetStatusBarColor(color.r, color.g, color.b)
		self.Power.bg:SetTexture(color.r, color.g, color.b, 0.2)
	else
		local color = (UnitIsPlayer(unit) and oUF.colors.power[UnitPowerType(unit)]) or UnitReactionColor[UnitReaction(unit, "player")]
		if(color) then 
			self.Power:SetStatusBarColor(color.r, color.g, color.b)
			self.Power.bg:SetTexture(color.r, color.g, color.b, 0.2)
		end
	end
end

--[[Auras reskin code ]]--
local auraIcon = function(self, button)
 	button.icon:SetTexCoord(.07, .93, .07, .93)
 	
 	local tex = button:CreateTexture(nil, "OVERLAY")
	tex:SetTexture(buffborder)
 	tex:SetAllPoints(button)
 	
 	-- make it color right
 	if(button.overlay) then
		button.overlay:Hide()
 		button.overlay = tex
 	else
 		tex:SetVertexColor(.25,.25,.35)
	end
 end
--[[Auras offset code ]]--
local auraOffset = function(self, icons, x)
	local total, col, row, size, anchor, button, growthx, growthy, cols, rows
	if(icons and x > 0) then
		col = 0
		row = 0
		size = icons.size or 16
		anchor = icons.initialAnchor or "BOTTOMLEFT"
		growthx = (icons["growth-x"] == "LEFT" and -1.1) or 1.1 -- This is the offset
		growthy = (icons["growth-y"] == "DOWN" and -1.1) or 1.1 -- This is the offset
		cols = math.floor(icons:GetWidth() / size)
		rows = math.floor(icons:GetHeight() / size)

		for i = 1, x do
			button = icons[i]
			button:ClearAllPoints()
			button:SetPoint(anchor, icons, anchor, col * size * growthx, row * size * growthy)

			if(col >= cols) then
				col = 0
				row = row + 1
			else
				col = col + 1
			end
		end
	end
end

-- Gigantic function of doom!
local func = function(settings, self, unit)
	self.menu = menu
	self:EnableMouse(true)
	self:SetScript("OnEnter", UnitFrame_OnEnter)
	self:SetScript("OnLeave", UnitFrame_OnLeave)
	self:RegisterForClicks"anyup"
	self:SetAttribute("*type2", "menu")

	-- Backdrop
	self:SetBackdrop{
		bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", tile = true, tileSize = 16,
		insets = {left = -3, right = -3, top = -3, bottom = -2},
	}
	self:SetBackdropColor(0,0,0,1)
	
	-- Hp bar
	local hp = CreateFrame"StatusBar"
	hp:SetHeight(20)
	hp:SetStatusBarTexture(statusbar)
	hp:SetStatusBarColor(.25,.25,.25)
	hp:SetParent(self)
	hp:SetPoint"TOP"
	hp:SetPoint"LEFT"
	hp:SetPoint"RIGHT"
	-- Hp bar bg
	local hpbg = hp:CreateTexture(nil, "BORDER")
	hpbg:SetAllPoints(hp)
	hpbg:SetTexture(0, 0, 0, 0)
	-- Hp text
	local hpp = hp:CreateFontString(nil, "OVERLAY")
	hpp:SetPoint("RIGHT", -2, -2)
	hpp:SetFont(font, 12, "OUTLINE")
	hpp:SetTextColor(1, 1, 1)
	-- Hp references
	hp.bg = hpbg
	hp.value = hpp
	self.Health = hp
	self.OverrideUpdateHealth = updateHealth

	-- Mp bar
	local pp = CreateFrame"StatusBar"
	pp:SetHeight(2)
	pp:SetStatusBarTexture(statusbar)
	pp:SetParent(self)
	pp:SetPoint"LEFT"
	pp:SetPoint"RIGHT"
	pp:SetPoint("TOP", hp, "BOTTOM", 0, -2)
	-- Mp bar bg
	local ppbg = pp:CreateTexture(nil, "BORDER")
	ppbg:SetAllPoints(pp)
	hpbg:SetTexture(0, 0, 0, 0)
	-- Mp text
	local ppp = pp:CreateFontString(nil, "OVERLAY")
	ppp:SetPoint("RIGHT", hpp, "LEFT", 0, 0)
	ppp:SetFont(font, 12, "OUTLINE")
	ppp:SetTextColor(1, 1, 1)
	-- Mp references
	pp.value = ppp
	pp.bg = ppbg
	self.Power = pp
	self.OverrideUpdatePower = updatePower

	-- leader icon
	local leader = hp:CreateTexture(nil, "OVERLAY")
	leader:SetHeight(16)
	leader:SetWidth(16)
	leader:SetPoint("TOPLEFT", self, 0, 8)
	leader:SetTexture"Interface\\GroupFrame\\UI-Group-LeaderIcon"
	self.Leader = leader

	-- raid target icon
	local icon = hp:CreateTexture(nil, "OVERLAY")
	icon:SetHeight(16)
	icon:SetWidth(16)
	icon:SetPoint("TOP", self, 0, 8)
	icon:SetTexture"Interface\\TargetingFrame\\UI-RaidTargetingIcons"
	self.RaidIcon = icon

	-- name
	local name = hp:CreateFontString(nil, "OVERLAY")
	name:SetPoint("TOPLEFT", self, "TOPLEFT", 2, -2)
	name:SetJustifyH("CENTER")
	name:SetFont(font, 12, "OUTLINE")
	name:SetShadowOffset(.8, -.8)
	name:SetShadowColor(0, 0, 0, 1)
	self.Name = name
	self.UNIT_NAME_UPDATE = updateName
	
	if unit=="player" then -- Player frame modification
		if LibDruidMana then -- Show druidbar values
			local druid = hp:CreateFontString(nil, "OVERLAY")
			druid:SetFont(font, 12, "OUTLINE")
			druid:SetTextColor(.8,.8,.8) 
			druid:SetPoint("CENTER", pp)
			druidMana = druid
		end
		
		name:ClearAllPoints()
		name:SetPoint("LEFT", self, "TOPLEFT", 2, 2)
		name:SetFont(font, 14, "OUTLINE")
		name:SetShadowOffset(.8, -.8)
		name:SetShadowColor(0, 0, 0, 1)
		hp:SetHeight(15)
		hpp:ClearAllPoints()
		hpp:SetPoint("TOPRIGHT", hp, "BOTTOMRIGHT", 0, -10)
		ppp:ClearAllPoints()
		ppp:SetPoint("TOPLEFT", hp, "BOTTOMLEFT", 0, -10)
		pp:SetHeight(4)
	end
	
	if unit=="target" then -- Target frame modification
	
		  local level = hp:CreateFontString(nil, "OVERLAY")
		level:SetPoint("TOPLEFT", self.Health, "TOPRIGHT", 5, 0)
		level:SetJustifyH("LEFT")
		level:SetFont(font, 22, "OUTLINE")
		self.Level = level
		self.UNIT_LEVEL = updateLevel
		  local class = hp:CreateFontString(nil, "OVERLAY")
		class:SetPoint("TOPLEFT", self.Level, "BOTTOMLEFT", -1, 0)
		class:SetJustifyH("LEFT")
		class:SetFont(font, 12, "OUTLINE")
		self.Class = class
		  local debuffs = CreateFrame("Frame", nil, self)
		debuffs:SetHeight(30)
		debuffs:SetWidth(280)
		debuffs:SetPoint("TOPLEFT", self.Health, "BOTTOMLEFT", -2, -25)
		debuffs.size = 30
		debuffs.num = 12
		debuffs.filter = false
		self.Debuffs = debuffs
		  local buffs = CreateFrame("Frame", nil, self)
		buffs:SetHeight(30)
		buffs:SetWidth(280)
		buffs:SetPoint("TOPLEFT", self.Health, "TOPLEFT", -3, 33)
		buffs.size = 30
		buffs.num = 40
		buffs.filter = false
		self.Buffs = buffs
		
		hp:SetHeight(15)
		pp:SetHeight(4)
		name:ClearAllPoints()
		name:SetPoint("RIGHT", self, "TOPRIGHT", -2, 2)
		name:SetFont(font, 14, "OUTLINE")
		name:SetShadowOffset(.8, -.8)
		name:SetShadowColor(0, 0, 0, 1)
		ppp:ClearAllPoints()
		ppp:SetPoint("TOPRIGHT", hp, "BOTTOMRIGHT", 0, -10)
		hpp:ClearAllPoints()
		hpp:SetPoint("TOPLEFT", hp, "BOTTOMLEFT", 0, -10)

		if combo then
			  local cpoints = self:CreateFontString(nil, "OVERLAY")
			cpoints:SetPoint("RIGHT", self, "LEFT", -9, 3)
			cpoints:SetFont(font, 38)
			cpoints:SetTextColor(1,1,1)
			cpoints:SetJustifyH"RIGHT" 
			self.CPoints = cpoints
		end
	end
	
	if unit=="pet" or unit=="pettarget" then -- Pet and Pet's target frame modification
		hp:SetHeight(10)
		pp:SetHeight(2)
		ppp:Hide()
		name:SetFont(font, 12, "OUTLINE")
		name:ClearAllPoints()
		name:SetPoint("TOPLEFT", hp, "BOTTOMLEFT", 0, -6)
		hpp:ClearAllPoints()
		hpp:SetPoint("TOPRIGHT", hp, "BOTTOMRIGHT", 0, -6)
		hpp:SetFont(font, 12, "OUTLINE")
		hpp:SetJustifyH("RIGHT")
		
		if unit=="pettarget" then -- Pet's target frame only modification
			name:ClearAllPoints()
			name:SetPoint("TOP", hp, "BOTTOM", 0, -6)
			hpp:Hide()
			name:SetWidth(145)
		end
	end
	
	if unit=="targettarget" or unit=="focus" then -- ToT and Focus frames modifications
		hp:SetHeight(6)
		pp:Hide()
		ppp:Hide()
		hpp:ClearAllPoints()
		hpp:SetPoint("TOPRIGHT", hp, "BOTTOMRIGHT", 0, -5)
		name:ClearAllPoints()
		name:SetPoint("TOPLEFT", hp, "BOTTOMLEFT", 0, -5)
	end
	
	if(self:GetParent():GetName():match"oUF_Party") then -- Party frames modifications
		hp:SetHeight(10)
		pp:SetHeight(3)
		ppp:Hide()
		name:SetFont(font, 12, "OUTLINE")
		name:ClearAllPoints()
		name:SetPoint("TOPLEFT", self.Health, "BOTTOMLEFT", 0, -10)
		hpp:ClearAllPoints()
		hpp:SetPoint("TOPRIGHT", self.Health, "BOTTOMRIGHT", 0, -10)
		hpp:SetFont(font, 12, "OUTLINE")
		hpp:SetJustifyH("RIGHT")
		
		  local debuffs = CreateFrame("Frame", nil, self)
		debuffs:SetHeight(30)
		debuffs:SetWidth(180)
		debuffs:SetPoint("LEFT", self.Health, "LEFT", -1,24)
		debuffs.size = 30
		debuffs.num = 5
		debuffs.filter = false
		self.Debuffs = debuffs
	end
	
	if(self:GetParent():GetName():match"oUF_Raid") then -- Raid frames modifications
		name:SetFont(font, 12, "OUTLINE")
		name:ClearAllPoints()
		name:SetPoint("TOPLEFT", self.Health, "BOTTOMLEFT", 0, -8)
		hpp:SetFont(font, 12, "OUTLINE")
		hpp:ClearAllPoints()
		hpp:SetPoint("TOPRIGHT", self.Health, "BOTTOMRIGHT", 2, -8)
		ppp:Hide()
		hp:SetHeight(10)
		pp:SetHeight(3)
			
		  local debuffs = CreateFrame("Frame", nil, self)
		debuffs:SetHeight(30)
		debuffs:SetWidth(140)
		debuffs:SetPoint("LEFT", self.Health, "LEFT", 145, -7)
		debuffs.size = 30
		debuffs.num = 3
		debuffs.filter = false
		self.Debuffs = debuffs
		
		  local missing = hp:CreateFontString(nil, "OVERLAY") -- Missing hp only displayed on raid frames
		missing:SetPoint("CENTER", self.Health, "CENTER", 0, 0)
		missing:SetJustifyH("CENTER")
		missing:SetFont(font, 12, "OUTLINE")
		self.Missing = missing
	end

	if(not unit) then -- fadeout on range
		self.Range = true -- put true to make party/raid frames fade out if not in your range
		self.inRangeAlpha = 1
		self.outsideRangeAlpha = .3 -- and the alpha it will fade out to 
	end

	-- Enable custom aura textures
    self.PostCreateAuraIcon = auraIcon
	self.SetAuraPosition = auraOffset

	return self
end

oUF:RegisterStyle("Party", setmetatable({
	["initial-width"] = 180,
	["initial-height"] = 25,
}, {__call = func}))

oUF:RegisterStyle("Raid", setmetatable({
	["initial-width"] = 140,
	["initial-height"] = 25,
}, {__call = func}))

-- Spawn the frames we want
  local player = oUF:Spawn("player", "oUF_Player")
player:SetPoint("CENTER", -300, -150)
player:SetHeight(30)
player:SetWidth(300)
  local target = oUF:Spawn"target"
target:SetPoint("CENTER", 300, -150)
target:SetHeight(30)
target:SetWidth(300) 
  local pet = oUF:Spawn"pet"
pet:SetPoint("TOPLEFT", player, "BOTTOMLEFT", 0, -20)
pet:SetHeight(22)
pet:SetWidth(145) 
  local pettarget = oUF:Spawn"pettarget"
pettarget:SetPoint("TOPRIGHT", player, "BOTTOMRIGHT", 0, -20)
pettarget:SetHeight(22)
pettarget:SetWidth(145) 
  local tot = oUF:Spawn"targettarget"
tot:SetPoint("CENTER", 0, -175)
tot:SetHeight(7)
tot:SetWidth(202) 
  local focus = oUF:Spawn"focus"
focus:SetPoint("TOP", 0, -30)
focus:SetHeight(7)
focus:SetWidth(202)

----------------------------
oUF:SetActiveStyle("Party")
----------------------------
  [[
  local party = oUF:Spawn("party")
party:SetPoint("BOTTOM", 0, 140)
party:SetManyAttributes("xOffset", 20, "point", "LEFT")

 local party1target = oUF:Spawn("party1target")
party1target:SetPoint("LEFT", oUF_PartyUnitButton1, "BOTTOMLEFT", 0, -20)
party1target:SetHeight(7)
party1target:SetWidth(180)
party1target.hp:SetHeight(7)

  local party2target = oUF:Spawn("party2target")
party2target:SetPoint("LEFT", oUF_PartyUnitButton2, "BOTTOMLEFT", 0, -20)
party2target:SetHeight(7)
party2target:SetWidth(180)
party1target.hpbg:SetHeight(7)

  local party3target = oUF:Spawn("party3target")
party3target:SetPoint("LEFT", oUF_PartyUnitButton3, "BOTTOMLEFT", 0, -20)
party3target:SetHeight(7)
party3target:SetWidth(180)
party1target.hpbg:SetHeight(7)

  local party4target = oUF:Spawn("party4target")
party4target:SetPoint("LEFT", oUF_PartyUnitButton4, "BOTTOMLEFT", 0, -20)
party4target:SetHeight(7)
party4target:SetWidth(180)
party1target.hpbg:SetHeight(7)
]]
--[[ comment the line above, and uncomment the line below to have party on top of each other instead of side by side.]]
--party:SetManyAttributes("yOffset", -20, "point", "TOP")

----------------------------
oUF:SetActiveStyle("Raid")
----------------------------
-- Only 3 groups spawned as i dont need more, but you can easily add more by following the pattern.
  local raid1 = oUF:Spawn("raid", 1)
		raid1:SetManyAttributes("groupFilter", "1", "yOffset", -15)
		raid1:SetPoint("TOPLEFT", 20, -20)
  local raid2 = oUF:Spawn("raid", 2)
		raid2:SetManyAttributes("groupFilter", "2", "yOffset", -15)
		raid2:SetPoint("TOPRIGHT", raid1, "BOTTOM", 70, -20)
  local raid3 = oUF:Spawn("raid", 3)
		raid3:SetManyAttributes("groupFilter", "3", "yOffset", -15)
		raid3:SetPoint("TOPRIGHT", raid2, "BOTTOM", 70, -20)
  local raid4 = oUF:Spawn("raid", 4)
		raid4:SetManyAttributes("groupFilter", "4", "yOffset", -15)
		raid4:SetPoint("TOPRIGHT", raid3, "BOTTOM", 70, -20)
  local raid5 = oUF:Spawn("raid", 5)
		raid5:SetManyAttributes("groupFilter", "5", "yOffset", -15)
		raid5:SetPoint("TOPRIGHT", raid4, "BOTTOM", 70, -20)
--[[ comment the lines above, and uncomment the lines below to have 1 raid frame showing all raid member.]]
--  local raid = oUF:Spawn"raid"
--raid:SetManyAttributes("groupFilter", "1,2,3,4,5,6,7,8", "yOffset", -10)
--raid:SetPoint("BOTTOM", -480, 30)

--[[ List of the various configuration attributes, taken from the SecureTemplates.lua
======================================================
showRaid = [BOOLEAN] -- true if the header should be shown while in a raid
showParty = [BOOLEAN] -- true if the header should be shown while in a party and not in a raid
showPlayer = [BOOLEAN] -- true if the header should show the player when not in a raid
showSolo = [BOOLEAN] -- true if the header should be shown while not in a group (implies showPlayer)
nameList = [STRING] -- a comma separated list of player names (not used if 'groupFilter' is set)
groupFilter = [1-8, STRING] -- a comma seperated list of raid group numbers and/or uppercase class names and/or uppercase roles
strictFiltering = [BOOLEAN] - if true, then characters must match both a group and a class from the groupFilter list
point = [STRING] -- a valid XML anchoring point (Default: "TOP")
xOffset = [NUMBER] -- the x-Offset to use when anchoring the unit buttons (Default: 0)
yOffset = [NUMBER] -- the y-Offset to use when anchoring the unit buttons (Default: 0)
sortMethod = ["INDEX", "NAME"] -- defines how the group is sorted (Default: "INDEX")
sortDir = ["ASC", "DESC"] -- defines the sort order (Default: "ASC")
template = [STRING] -- the XML template to use for the unit buttons
templateType = [STRING] - specifies the frame type of the managed subframes (Default: "Button")
groupBy = [nil, "GROUP", "CLASS", "ROLE"] - specifies a "grouping" type to apply before regular sorting (Default: nil)
groupingOrder = [STRING] - specifies the order of the groupings (ie. "1,2,3,4,5,6,7,8")
maxColumns = [NUMBER] - maximum number of columns the header will create (Default: 1)
unitsPerColumn = [NUMBER or nil] - maximum units that will be displayed in a singe column, nil is infinate (Default: nil)
startingIndex = [NUMBER] - the index in the final sorted unit list at which to start displaying units (Default: 1)
columnSpacing = [NUMBER] - the ammount of space between the rows/columns (Default: 0)
columnAnchorPoint = [STRING] - the anchor point of each new column (ie. use LEFT for the columns to grow to the right)
--]]